package com.fxd.crm.service.impl.studentImpl;

import com.fxd.crm.mapper.studentMapper;
import com.fxd.crm.model.CourseOrder;
import com.fxd.crm.model.PageResult;
import com.fxd.crm.model.student;
import com.fxd.crm.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @auther fuxudong
 * @date 2021/4/4 - 19:56
 */
@Service
public class studentImpl implements IStudentService {

    @Autowired
    studentMapper studentMapper;


    @Override
    public PageResult<student> findPageResult(student student, int Page, int PageSize) {
        PageResult<student> result = new PageResult<>();
        result.setCode(0);
        Map<String, Object> params = new HashMap<>();
        params.put("condition", student);
        params.put("start", (Page - 1) * PageSize);
        params.put("pageSize", PageSize);
        int count = studentMapper.findCountByMap(params);
        result.setCount(count);
        //获取查询的数据
        List<student> list = studentMapper.findListByMap(params);
        result.setData(list);
        return result;
    }

    @Override
    public void save(student student) {
        studentMapper.insert(student);
    }


    @Override
    public student findByUuid(Integer uuid) {
        student student = studentMapper.findByUuid(uuid);
        return student;
    }
    @Override
    public student findByName(String name) {
        student student = studentMapper.findByName(name);
        return student;
    }

    @Override
    public void deleteByUuid(Integer uuid) {
        studentMapper.deleteByUuid(uuid);
    }

    @Override
    public void update(student student) {
        studentMapper.update(student);
    }
}
